package com.rongke.web;

import com.rongke.commons.JsonResp;
import com.rongke.model.ExpRecComment;
import com.rongke.service.ExpRecCommentService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @ExpRecCommentController
 * @体验推荐评论Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/expRecComment")
@Transactional
@CrossOrigin
public class ExpRecCommentController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private ExpRecCommentService expRecCommentService;

    /**
     * @添加体验推荐评论
     * @param expRecComment
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/addComment", method = RequestMethod.POST)
    public JsonResp addExpRecComment(@RequestBody ExpRecComment expRecComment){
        log.debug("添加体验推荐评论");
        expRecComment.setGmtDatetime(new Date());
        expRecCommentService.insert(expRecComment);
        return JsonResp.ok(expRecComment);
    }

    /**
     * @修改体验推荐评论
     * @param expRecComment
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateExpRecComment(@RequestBody ExpRecComment expRecComment){
        log.debug("修改体验推荐评论");
        expRecCommentService.updateById(expRecComment);
        return JsonResp.ok(expRecComment);
    }
    /**
     * @根据id查找体验推荐评论
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectExpRecComment(Long id){
        log.debug("查找体验推荐评论");
        ExpRecComment expRecComment = expRecCommentService.selectById(id);
        return JsonResp.ok(expRecComment);
    }



}
